class Questionnaire < ActiveRecord::Base
  has_many :questions, :dependent => :destroy
  belongs_to :company
  
  scope :of_company, lambda { |company|
      {:conditions => ['company_id = ?', company]}}
  
    
  def self.getPolygon(str)
    lats = str.split(',')
    
    text = lats[0] + " " + lats[1] + ", " + lats[2] + " " + lats[3] + ", " + lats[4] + " " + lats[5] + ", " + lats[6] + " " + lats[7] + ", " + lats[0] + " " + lats[1]
    
    text = "POLYGON((" + text + "))"
    
    pol = Polygon.from_ewkt(text)
    
    #pol = Polygon.from_points(p)
    #pol = Polygon.from_coordinates([lats[0], lats[1]], [lats[2], lats[3]], [lats[4], lats[5]], [lats[6], lats[7]])
    return pol;
  end
end
